package com.hspedu.newData.面试题;

import com.hspedu.newData.dmsxl.ds.ListNode;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-21 
 * @Version: 1.0
 */

public class 面试题0207链表相交 {

    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {

        ListNode pA = headA;
        ListNode pB = headB;

        while (pB != pA){

            pA = pA != null ? pA.next : pB;
            pB = pB != null ? pB.next : pA;
        }

        return pA;

    }

}
